<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    <script>
        //我们要注册一个会员，首先先新建两个单类
        //身份类
        var Identity = function(){
            this.status = '是会员身份'
        }
        //姓名类
        var Name =  function(name){
            //下面会形成闭包
            //对this进行baocun
            let self = this
            //立即hanshu 
            (function(name,self){
                self.wholename = name
                //对姓和名进行切割
                //对首次出现空格的地方进行检测
                if(name.indexOf(' ') > -1){
                    self.firstname = name.slice(0,name,indexOf(' '))
                    self.lastname = name.slice(indexOf(' '))
                }
            })(name,self)
        }
         //会员种类
         var memberr = function(type){
            var self = this
            (function(type,self){
                switch(type){
                    case 1:
                    case 10:
                        self.member = '白银'
                        break;
                    case 11:
                    case 20:
                        self.member = '黄金'
                    default:
                        self.member = '荣耀'
                }
            })(type,self)
         }
         memberr.prototype = function(){
             return this.member
         }
         //人注册会员
         var Person = function (){
            var identity = new Identity()
            identity.name = new Name()
            identity.member = new memberr()
         }
    </script>
</body>
</html>